package days48;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

public class four {
    //第一题
    public static void main1(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int[] arr=new int[4];
        for (int i=0;i<4;) {
            int a=scanner.nextInt();
            arr[i++]=a;
        }
        if(arr[0]-arr[1]!=arr[2]-arr[3]){
            System.out.println("NO");
        }
        int a=(arr[0]+arr[2])/2;
        int b=a-arr[0];
        int c=arr[3]-b;
        System.out.println(a+" "+b+" "+c);
    }
    //第二题
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int[] arr=new int[2];
        for (int i = 0; i < 2; i++) {
            int a=scanner.nextInt();
            arr[i]=a;
        }
        Stack<Object>stack=new Stack<>();
        int b=arr[0];
        int c=arr[1];
        char[]str=new char[]{'a','b','c','d','e','f'};
        int d=0;
        while (b!=0){
            d=b%c;
            if(d>=10){
                stack.add(str[(d%10)]);
            }else {
                stack.add(d);
            }
            b/=c;
        }
        int k=stack.size();
        for (int i = 0; i < k; i++) {
            System.out.print(stack.pop());
        }
    }
}
